package com.qianji.service.impl;

import com.qianji.mapper.JumpLogMapper;
import com.qianji.mapper.SalesUrlMapper;
import com.qianji.pojo.JumpLogDto;
import com.qianji.pojo.SalesUrlDto;
import com.qianji.service.SalesUrlService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

@Service
public class SalesUrlServiceImpl implements SalesUrlService {

    @Autowired
    private SalesUrlMapper salesUrlMapper;

    @Autowired
    private JumpLogMapper jumpLogMapper;

    @Override
    @Transactional
    public SalesUrlDto findById(Long id) {

        SalesUrlDto salesUrlDto = salesUrlMapper.findById(id);
        JumpLogDto jumpLogDto = new JumpLogDto();
        jumpLogDto.setActivityId(id);
        jumpLogDto.setQjUrl(salesUrlDto.getUrl());
        jumpLogDto.setJumpUrl(salesUrlDto.getLinkUrl());
        jumpLogDto.setCreateTime(new Date());
        //插入数据
        Integer status = jumpLogMapper.insertJumpLog(jumpLogDto);
        if(status != 1){
            System.out.println("插入数据失败");
        }

        return salesUrlDto;
    }
}
